package com.zenkeeuk.bookerfornfc.client.android.book;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zenkeeuk.bookerfornfc.client.android.Contents;
import com.zenkeeuk.bookerfornfc.client.android.R;

import android.content.Context;
import android.widget.SimpleAdapter;

public class LabBookListAdapter extends SimpleAdapter {

    private static List<Map<String, Object>> reviews;

    public LabBookListAdapter(Context context, List<LabBookInfo> data) {
    	super(context, getData(data), 
    			R.layout.labsearch, 
    			new String[]{Contents.LAB_BOOK_NAME_KEY, 
    						 Contents.LAB_BOOK_REMARK_KEY, 
    						 Contents.LAB_BOOK_LAB_NAME_KEY,
    						 Contents.LAB_BOOK_LAB_LOCATION_KEY }, 
    			new int[]{R.id.labbook_name, 
    					  R.id.labbook_remark, 
    					  R.id.labbook_libraryname,
    					  R.id.labbook_liblocation});
    }
    
    private static List<Map<String, Object>> getData(List<LabBookInfo> data) {
    	reviews = new ArrayList<Map<String, Object>>();
    	
    	for (int i=0;i<data.size();i++) {
	    	HashMap<String, Object> map = new HashMap<String, Object>();
	    	map.put(Contents.LAB_BOOK_NAME_KEY, data.get(i).getBookName());
            map.put(Contents.LAB_BOOK_REMARK_KEY, data.get(i).getRemark());
	    	map.put(Contents.LAB_BOOK_LAB_NAME_KEY, data.get(i).getLibraryName());
	    	map.put(Contents.LAB_BOOK_LAB_LOCATION_KEY, data.get(i).getLocation());
	    	reviews.add(map);
    	}
    	
    	return reviews;
    }
}
